package com.example.timedemo;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import java.util.Timer;
import java.util.TimerTask;

/**
 * 作者：xuqing
 * 时间：2023年10月24日15:08:15
 * 邮箱：1693891473@qq.com
 * 说明：定时器服务
 */
public class ScheduledService extends Service {
    private static final String TAG = "ScheduledService";
    private Timer timer = new Timer();
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LogUtils.e( "onCreate: " +"哈哈哈");
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                sendRequestToServer();   //Your code here
            }
        }, 0, 5*1000);//5 Minutes
    }


    @Override
    public void onDestroy() {
        super.onDestroy();

    }

    private void sendRequestToServer() {
        LogUtils.e( "sendRequestToServer: " +"哈哈哈");
    }

}